﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Faculty
{
    class Group
    {
        public string Name;
        public List<Student> Students = new List<Student>();
        private static int groupCount;

        public void GenerateGroup()
        {
            Random rnd = new Random();
            Name = "Intetics-" + Group.groupCount;
            groupCount++;
            for (int i = 0; i < 5; i++)
            {
                Student student = new Student();
                student.GenerateRandomStudent();
                Students.Add(student);
            }
        }

        public void PrintGroupToConsole()
        {
            Console.WriteLine("Group Name: {0}", Name);
            PrintStudentsToConsole();
        }

        public void PrintStudentsToConsole()
        {
            foreach (var student in Students)
            {
                student.PrintStudentToConsole();
                Console.WriteLine("======");
            }
        }

        public void PrintBestStudents()
        {
            foreach (var student in Students)
            {
                bool isStudentExist = false;

                if (student.GetAverageMark() > 50)
                {
                    Console.WriteLine("{0} {1} {2}",student.FirstName, student.LastName, student.GetAverageMark());
                    isStudentExist = true;
                }
                if (!isStudentExist)
                {
                    Console.WriteLine("Таких студентов нет");
                }
            }
        }
    }
}
